// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "OpenableBox.generated.h"


class UBoxComponent;

UCLASS()
class HOMEWORK3_API AOpenableBox : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AOpenableBox();

	UPROPERTY()
		USceneComponent* Scene;
	UPROPERTY(VisibleAnywhere)
		UStaticMeshComponent* BoxMesh;
	UPROPERTY(VisibleAnywhere)
		UStaticMeshComponent* TopMesh;


	UFUNCTION(BlueprintCallable)
		virtual void OpenBox();

	UFUNCTION()
		virtual void OpenByPresent();

	UFUNCTION(BlueprintCallable)
		virtual void CloseBox();

	UFUNCTION()
		virtual void CloseByPresent();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	UPROPERTY(BlueprintReadWrite, EditAnywhere,meta=(UIMin=0,UIMax=20))
	float fOpenTime=1;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (UIMin = 0, UIMax = 20))
	float fCloseTime = 1;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (UIMin = 0, UIMax = 1))
	float fOpenPersent=0;

	UPROPERTY(BlueprintReadWrite, EditAnywhere)
		bool bIsOpened = false;

	FTimerHandle TimerHandleOpen;
	FTimerHandle TimerHandleClose;
	bool bIsAnimating;
};
